<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>理财包</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
    <link href="../plugin/jquery-zoomify/zoomify.min.css" rel="stylesheet"/>

    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/local_zh.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/jquery-zoomify/zoomify.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/soul/utils3.js"></script>
    <script src='../base/base.js'></script>
</head>

<body>

</body>
<script>
    $(function () {
        var resp = AjaxUtil.isLogin();
        if (!resp) return;
        var module = 'financial';// 权限模块
        var query = [];
        var toolbar = {
            default: [false, true, true, true],// back;add;edit;remove
            dialog: [50, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '理财明细',
                glyphicon: 'user',
                onclick: 'showFinancailUser',
            },]
        };
        var formElement = [{
            action: [false, true],
            type: 'hidden', // 表单类型
            name: 'financialId', // 字段名称
        }, {
            action: [true, true],
            type: 'text',
            label: '名称',
            name: 'name',
        },{
            action: [true, true],
            type: 'text',
            label: '名称(英文)',
            name: 'englishName',
        }, {
            action: [true, true],
            type: 'text',
            label: '标题',
            name: 'title',
        },{
            action: [true, true],
            type: 'text',
            label: '理财编号',
            name: 'code',
        },{
            action: [true, true],
            type: 'text',
            label: '预期年化',
            name: 'annualEarnings',
        },{
            action: [true, true],
            type: 'radio',
            label: '投资期限',
            name: 'investmentDeadline',
            items: [{
                name: '短期',
                value: '1'
            }, {
                name: '中长期',
                value: '2'
            }, {
                name: '长期',
                value: '3'
            }]
        },{
            action: [true, true],
            type: 'radio',
            label: '投资类型',
            name: 'investmentType',
            items: [{
                name: 'BTC',
                value: '10'
            }, {
                name: 'ETH',
                value: '20'
            }, {
                name: 'BHPC',
                value: '100'
            }]
        },{
            action: [true, true],
            type: 'radio',
            label: '收益类型',
            name: 'earningsType',
            items: [{
                name: 'BTC',
                value: '10'
            }, {
                name: 'ETH',
                value: '20'
            }, {
                name: 'BHPC',
                value: '100'
            }]
        }, {
            action: [true, true],
            type: 'text',
            label: '总份额<br><small>单位:投资类型币种</small>',
            name: 'totalPortion',
        }, {
            action: [true, true],
            id: 'interestDate',
            type: 'date',
            label: '起息日',
            name: 'interestDate',
        }, {
            action: [true, true],
            type: 'text',
            label: '期限(单位:天)',
            name: 'deadline',
        }, {
            action: [true, true],
            type: 'text',
            label: '收益率(单位:%)<br>',
            name: 'earningsRate',
        }, {
            action: [true, true],
            type: 'text',
            label: '最小投资额',
            name: 'minInvestment',
        }, {
            action: [true, true],
            type: 'text',
            label: '最大投资额',
            name: 'maxInvestment',
        },{
            action: [true, true],
            type: 'radio',
            label: '是否上线',
            name: 'isOnline',
            items: [{
                name: '是',
                value: '1'
            }, {
                name: '不是',
                value: '2'
            }]
        }, {
            action: [true, true],
            type: 'text',
            label: '理财说明',
            name: 'description',
        },{
            action: [true, true],
            type: 'text',
            label: '理财说明(英文)',
            name: 'englishDescription',
        },{
            action: [true, true],
            type: 'text',
            label: '备注',
            name: 'remark',
        },];

        var bootstrapTable = {
            url: '',
            columns: [{
                radio: true
            }, {
                field: 'financialId',
                title: '理财ID',
                align: 'center',
            }, {
                field: 'name',
                title: '理财名称',
                align: 'center',
            },  {
                field: 'totalPortion',
                title: '总份额',
                align: 'center',
            },{
                field: 'leftPortion',
                title: '剩余份额',
                align: 'center',
            },{
                field: 'investmentType',
                title: '投资类型',
                formatter: function (value, row, index) {
                    if (value == 10) {
                        return 'BTC';
                    } else if (value == 20) {
                        return 'ETH';
                    } else if (value == 100) {
                        return 'BHPC';
                    } else {
                        return '未知';
                    }
                }
            },{
                field: 'investmentDeadline',
                title: '投资期限',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '短期';
                    } else if (value == 2) {
                        return '中长期';
                    } else if (value == 3) {
                        return '长期';
                    } else {
                        return '未知';
                    }
                }
            }, {
                field: 'deadline',
                title: '理财期限(天)',
            }, {
                field: 'minInvestment',
                title: '最小投资额',
                align: 'center',
            },{
                field: 'earningsType',
                title: '收益类型',
                formatter: function (value, row, index) {
                    if (value == 10) {
                        return 'BTC';
                    } else if (value == 20) {
                        return 'ETH';
                    } else if (value == 100) {
                        return 'BHPC';
                    } else {
                        return '未知';
                    }
                }
            },{
                field: 'earningsRate',
                title: '收益率(%)',
                align: 'center',
            },{
                field: 'isOnline',
                title: '是否上线发布',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '是';
                    } else if (value == 2) {
                        return '不是';
                    } else {
                        return '未知';
                    }
                }
            },{
                field: 'interestDate',
                title: '起息日',
                formatter: BootstrapTableUtil.formatter.datetime
            },]
        }

        // debugger;
        financial = SingleTablePageCreateUtil.createInstance(module, query, toolbar, formElement, bootstrapTable);

        financial.onEditModalShowBefore = function (row) {
            row.createDate = FormatUtil.formatDateTime(row.createDate);
            row.interestDate = FormatUtil.formatDateTime(row.interestDate);
            row.endIntersetDate = FormatUtil.formatDateTime(row.endIntersetDate);
            return row;
        };
        financial.onRemoveSubmitBefore = function (row) {
            row.createDate = FormatUtil.formatDateTime(row.createDate);
            row.interestDate = FormatUtil.formatDateTime(row.interestDate);
            row.endIntersetDate = FormatUtil.formatDateTime(row.endIntersetDate);
            return row;
        };

        financial.showFinancailUser = function () {
            var row = TablePageCreatePublicUtil.getRowFromTable('#financial_table');
            if (!row) return false;
            window.location.href = 'user_financial_record.html?financialId=' + row.financialId;
        };
    });
</script>
</html>